package com.heiye.comment.biz.rpc;

import com.heiye.framework.common.response.Response;
import com.heiye.quiz.api.api.QuizFeignApi;
import com.heiye.quiz.api.dto.req.FindQuizCreatorReqDTO;
import com.heiye.quiz.api.dto.resp.FindQuizCreatorRespDTO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * @author: heiye
 * @date: 2025/09/08 下午9:26
 * @version: v1.0.0
 * @description: 问题业务
 */
@Component
public class QuizRpcService {

    @Resource
    private QuizFeignApi quizFeignApi;

    /**
     * 查询问题作者信息
     *
     * @param quizId
     * @return
     */
    public Long findQuizCreatorId(Long quizId) {
        FindQuizCreatorReqDTO findQuizCreatorReqDTO = FindQuizCreatorReqDTO.builder()
                .quizId(quizId)
                .build();

        Response<FindQuizCreatorRespDTO> response = quizFeignApi.findQuizCreator(findQuizCreatorReqDTO);

        if (!response.isSuccess()) {
            return null;
        }

        return response.getData().getCreatorId();
    }
}
